<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap demo</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        crossorigin="anonymous">
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <!-- axios插件用于请求后端数据 -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<body>
    <div id="app" class="container-fluid">
        <div class="container-fluid">
            <nav class="navbar bg-black">
                <div class="container-fluid">
                    <a class="navbar-brand text-white" href="#">
                        工资管理系统
                    </a>
                </div>
            </nav>
        </div>
        <!-- 内容部分 -->
        <div class="container">
            <div class="row">
                <div class="col-4 bg-light">
                    <h1>部门管理</h1>
                </div>
                <div class="col-8">
                    <table class="table">
                        <thead>
                            <tr>
                                <th scope="col">部门编号</th>
                                <th scope="col">部门名称</th>
                                <th scope="col">部门地址</th>
                                <th scope="col">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="deptItem in deptList">
                                <th scope="row">{{deptItem.deptId}}</th>
                                <td>{{deptItem.deptName}}</td>
                                <td>{{deptItem.location}}</td>
                                <td>
                                    <button type="button" class="btn btn-primary btn-sm" @click="edit(deptItem.deptId)"
                                        data-bs-toggle="modal" data-bs-target="#editModal">编辑</button>
                                    &nbsp; &nbsp; &nbsp; &nbsp;
                                    <button type="button" class="btn btn-danger btn-sm"
                                        @click="del(deptItem.deptId)">删除</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 编辑弹窗 -->
        <div class="modal" tabindex="-1" id="editModal">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">编辑部门</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="input-group mb-3">
                            <span class="input-group-text" id="inputGroup-sizing-default">部门编号</span>
                            <input type="text" class="form-control" aria-label="Sizing example input"
                                aria-describedby="inputGroup-sizing-default" :value="curDeptId" readonly>
                        </div>
                        <div class="input-group mb-3">
                            <span class="input-group-text" id="inputGroup-sizing-default">部门名称</span>
                            <input type="text" class="form-control" aria-label="Sizing example input"
                                aria-describedby="inputGroup-sizing-default" v-model="curDeptName">
                        </div>
                        <div class="input-group mb-3">
                            <span class="input-group-text" id="inputGroup-sizing-default">部门地址</span>
                            <input type="text" class="form-control" aria-label="Sizing example input"
                                aria-describedby="inputGroup-sizing-default" :value="curDeptLocation" readonly>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">去取消</button>
                        <button type="button" class="btn btn-primary" data-bs-dismiss="modal" @click="save()">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="dept.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
        crossorigin="anonymous"></script>
</body>

</html>